<!-- 新增/编辑实验 -->
<template>
  <el-dialog title="新增实验" width="500" :model-value="modelValue" @close="commEvent.onClose">
    <el-form ref="formRef" :model="forms" :rules="rules">
      <el-form-item label="实验类型" prop="mock">
        <el-select v-model="forms.mock" placeholder="请选择实验类型" clearable>
          <el-option v-for="item in experimentOptions" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="实验名称" prop="mock">
        <el-input v-model="forms.mock" placeholder="请输入实验名称" />
      </el-form-item>
    </el-form>
    <template #footer>
      <el-button @click="commEvent.onClose">取消</el-button>
      <el-button type="primary">保存</el-button>
    </template>
  </el-dialog>
</template>

<script setup lang="ts">
import { FormInstance, FormRules } from "element-plus"
import { ref } from "vue"

defineProps({
  modelValue: { type: Boolean, default: false }
})
const emit = defineEmits(["update:modelValue", "refresh"])
// 参数
const formRef = ref<FormInstance>() // 表单实例
const experimentOptions = [
  { label: "自动化实验", value: "01" },
  { label: "手动实验", value: "02" }
]
// 表单参数
const forms = ref({ mock: "" })
// 表单校验
const rules: FormRules = {}
// 事件
const commEvent = {
  // 关闭弹窗
  onClose: () => {
    emit("update:modelValue", false)
  }
}
</script>

<style lang="scss" scoped></style>
